<?php
require('my_ui.inc');
require('my_cn.inc');
require('my_db.inc');
ui_print_header('register');
if(isset($_POST['register'])){
	insert_new_user();
}
else
{
	construct_register_form($_SERVER['SCRIPT_NAME']);
}

function construct_register_form()
{
ui_print_register_form($_SERVER['SCRIPT_NAME']);
}
function insert_new_user()
{
	$conn=db_connect($err);
	$insstmt="INSERT INTO USERS (UNAME,PASSWORD) 
			VALUES(:UNAME,:PASSWORD)";
/*	$stmt=oci_parse($conn,$insstmt);
	oci_bind_by_name($stmt,':UNAME',$_POST['uname']);
	oci_bind_by_name($stmt,':PASSWORD',$_POST['password']);
	oci_*/
	$bindargs=array();
	array_push($bindargs,array('UNAME',$_POST['uname'],-1));
	array_push($bindargs,array('PASSWORD',$_POST['password'],-1));
	$r=db_execute_statement($conn,$insstmt,$err,$bindargs);
	if($r)
	{
		echo '<p>Congratulations!, user'.$_POST['uname'].'created successfullly</p>';
		echo '<p>click <a href="login.php">here</a> to login </p>';
	}
}
ui_print_footer(date('Y-m-d H:i:s'));
?>